
import {requestInfo} from '@/api/public.js'

/**
 * 维修单
 */
export class RepairOrderService {
    // 分页查询列表
    static findRepairOrders (queryParams) {
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/findRepairOrders',
            method: 'POST',
            data: queryParams
        });
    }

    //根据ID查询指定的维修单
    static findRepairOrder (repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/findRepairOrder',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的维修单(包含外键名称)
    static findRepairOrderForView (repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/findRepairOrderForView',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的维修单(包含外键名称)
    static findRepairOrderForEdit (repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/findRepairOrderForEdit',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的维修单(只提取ID 和 Name)
    static findRepairOrdersWithIdNameById (repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/findRepairOrdersWithIdNameById',
            method: 'POST',
            params: query,
        });
    }

    //根据名称查询维修单集合(只提取ID 和 Name)
    static findRepairOrdersWithIdNameByName (repairOrderName) {
        const query = {
            repairOrderName
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/findRepairOrdersWithIdNameByName',
            method: 'POST',
            params: query,
        });
    }

    //新增保存维修单
    static saveRepairOrder (repairOrder) {
        const query = {}
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/saveRepairOrder',
            method: 'POST',
            params: query,
            data: repairOrder
        });
    }

    //修改保存维修单
    static updateRepairOrder (repairOrder) {
        const query = {}
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/updateRepairOrder',
            method: 'POST',
            params: query,
            data: repairOrder
        });
    }

    //根据ID查询指定的维修单(只提取ID 和 Name)
    static deleteRepairOrder (repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/deleteRepairOrder',
            method: 'POST',
            params: query,
        });
    }

    static updateStatus(currentState, status, setTimeName, repairOrderId) {
        const query = {
            currentState,
            status,
            setTimeName,
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/updateStatus',
            method: 'POST',
            params: query,
        });
    }

    static startRepair(repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/startRepair',
            method: 'POST',
            params: query,
        });
    }

    static endRepair(repairOrderId) {
        const query = {
            repairOrderId
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/endRepair',
            method: 'POST',
            params: query,
        });
    }
    static reminder(repairOrder) {
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/reminder',
            method: 'POST',
            data: repairOrder
        });
    }

    static findRepairStatusRecords(queryParams) {
        return requestInfo({
            url: '/repair/repairManagement/RepairOrderStatusRecord/findRepairOrderStatusRecords',
            method: 'POST',
            data: queryParams
        });
    }

    static chargeback(repairOrderId, reason) {
        const query = {
            repairOrderId,
            reason
        }
        return requestInfo({
            url: '/repair/repairManagement/RepairOrder/chargeback',
            method: 'POST',
            params: query,
        });
    }
}
